
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    request.setCharacterEncoding("utf-8");
    String username = request.getParameter("username");
    String password  = request.getParameter("password");

    Cookie usernameCookie = new Cookie("username",username);
    Cookie pwdCookie = new Cookie("password",password);
    usernameCookie.setMaxAge(1*20);
    pwdCookie.setMaxAge(1*20);

    //将cookie对象回写到客户端
    response.addCookie(usernameCookie);
    response.addCookie(pwdCookie);

    //重定向到其他页面，在获取客户端的cookie
    response.sendRedirect("getClientCookie.jsp");
%>